# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: damir <damir@archlinux.org>
# Contributor: Lukas Sabota <punkrockguy318@comcast.net>
# Contributor: Brice Carpentier <brice@dlfp.org>

pkgname=scons
pkgver=4.4.0
pkgrel=3
pkgdesc="Extensible Python-based build utility"
arch=(any)
url="https://scons.org"
license=(MIT)
depends=(python)
makedepends=(fop ninja python-build python-installer python-lxml python-setuptools
python-sphinx python-sphinx_rtd_theme python-wheel rst2pdf)
checkdepends=(python-psutil python-pytest)
source=(https://github.com/$pkgname/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('01fcd40bf818ca22a278973af1cda3024efb74cf877f15d46607fda860448fbd577fc96ba33fef2bed3d145e662a0371f55e8c927e7ac44feea7f3081791ce11')
b2sums=('f6ce757f2edc40551b05285098626bb62def6abda2380d4885ee4443868e715e53aaa34f26c09dc689bb6ade26d1b0e276046fe3b1d2ddf8eb40400bca9ea164')

build() {
  cd $pkgname-$pkgver
  python scripts/scons.py --include-dir= -j1
  python -m build --wheel --no-isolation
}

check() {
  cd $pkgname-$pkgver
  python runtest.py --all --unit-only
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  # remove man pages wrongly installed due to mishandling of install-data
  rm -fv "$pkgdir/usr/"*.1
  install -vDm 644 build/doc/man/*.1 -t "$pkgdir/usr/share/man/man1/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {{CHANGES,RELEASE}.txt,README.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
}
